<template>
  <el-dialog :title="title" :visible.sync="open" width="70%" @close="cancel">
    <!--<el-form :model="queryParams" ref="queryForm" v-show="showSearch" label-width="100px" class="form-flex">-->
      <!--<el-row :gutter="20">-->
        <!--<el-col :span="6" :xs="24">-->
          <!--<el-form-item label="房屋名称" prop="roomName">-->
            <!--<el-input-->
              <!--v-model="queryParams.roomName"-->
              <!--placeholder="请输入房屋名称"-->
              <!--clearable-->
              <!--size="small"-->
              <!--@keyup.enter.native="handleQuery"-->
            <!--/>-->
          <!--</el-form-item>-->
        <!--</el-col>-->
        <!--<el-col :span="6" :xs="24">-->
          <!--<el-form-item label="收费标准" prop="normId">-->
            <!--<el-input-->
              <!--v-model="queryParams.normId"-->
              <!--placeholder="请输入收费标准"-->
              <!--clearable-->
              <!--size="small"-->
              <!--@keyup.enter.native="handleQuery"-->
            <!--/>-->
          <!--</el-form-item>-->
        <!--</el-col>-->
        <!--<el-col :span="6" :xs="24">-->
          <!--<el-form-item label="计费截至日期" prop="paymentCycle">-->
            <!--<el-input-->
              <!--v-model="queryParams.paymentCycle"-->
              <!--placeholder="请输入计费截至日期"-->
              <!--clearable-->
              <!--size="small"-->
              <!--@keyup.enter.native="handleQuery"-->
            <!--/>-->
          <!--</el-form-item>-->
        <!--</el-col>-->
        <!--<el-col :span="6" :xs="24">-->
          <!--<el-form-item label-width="0">-->
            <!--<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>-->
            <!--<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>-->
          <!--</el-form-item>-->
        <!--</el-col>-->
      <!--</el-row>-->
    <!--</el-form>-->

    <el-table v-loading="loading" :data="payFeeLogList" size="mini">
      <el-table-column label="计费范围" align="center" show-overflow-tooltips>
        <template slot-scope="scope">
          {{ (getFeeExtent(scope.row)) }}
        </template>
      </el-table-column>
      <el-table-column label="收费项目" align="left" prop="chargeId" width="120" :formatter="itemFormat" show-overflow-tooltip />
      <el-table-column label="收费标准" align="center" prop="normNames" width="120" show-overflow-tooltip/>
      <el-table-column label="计费截至月" align="center" prop="paymentCycle" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.paymentCycle, '{y}-{m}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="计费时间" align="center" prop="createTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="费用单条数" align="center" prop="feeNum" width="100">
        <template slot-scope="scope">
          <el-link type="primary" @click="handleLook(scope.row)">{{scope.row.feeNum}}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status" width="100">
        <template slot-scope="scope">
          {{ dict.label.sys_common_status[scope.row.status] }}
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <compute-fee-detail ref="feeDetail" />
  </el-dialog>
</template>

<script>
  import { computePayFeeLogList } from "@/api/payfee/tollCenter";
  import { listMixin } from "@/utils/mixins/listMixin";
  import { payFeeDictMixin } from "@/utils/mixins/payFeeDictMixin";
  import ComputeFeeDetail from "./computeFeeDetail"
  export default {
    name: "computePayFeeLog", //计算日志
    dicts: ['sys_common_status'],
    mixins:[ listMixin,payFeeDictMixin ],
    components:{ ComputeFeeDetail },
    data() {
      return {
        open:false,
        title:'计算费用日志',
        payFeeLogList: [],
        loading: false,
        total: 0,
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          communityId: null,
          floorId: null,
          unitId: null,
          roomId: null
        },
        currentNode:{}
      }
    },
    methods: {
      show(option){
        this.currentNode = option.currentNode
        this.open = true
        this.getList()
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      getList() {
        if(this.currentNode.modelType == 'community' ){
          this.queryParams.communityId = this.currentNode.id
        }else  if(this.currentNode.modelType == 'floor' ){
          this.queryParams.floorId = this.currentNode.id
        }else  if(this.currentNode.modelType == 'unit' ){
          this.queryParams.unitId = this.currentNode.id
        }else  if(this.currentNode.modelType == 'room' ){
          this.queryParams.roomId = this.currentNode.id
        }
        computePayFeeLogList(this.queryParams).then(res => {
          this.payFeeLogList = res.rows
          this.total = res.total
        });
      },
      cancel() {
        this.open = false;
        this.reset();
      },
      reset(){
        this.queryParams.communityId =  null
        this.queryParams.floorId =  null
        this.queryParams.unitId =  null
        this.queryParams.roomId =  null

      },
      handleLook(row){
        this.$refs.feeDetail.show({batcheNo:row.id})
      },
      getFeeExtent(row){
        let feeExtent = []
        if(row.communityName){
          feeExtent.push(row.communityName)
        }
        if(row.floorName){
          feeExtent.push(row.floorName)
        }
        if(row.unitName){
          feeExtent.push(row.unitName)
        }
        if(row.roomNum){
          feeExtent.push(row.roomNum)
        }
        return feeExtent.join("-")
      }
    }
  }
</script>

<style>
</style>
